<template>
  <div class="container" id="pdfDom">
    <!-- 头部 -->
    <div class="head">
      <div class="head-title">个人简历</div>
      <div class="head-line">|</div>
      <div class="head-content">
        <div>细心从每一个小细节开始</div>
        <div>Personal resume</div>
      </div>

      <div class="icon">
        <svg-icon name="library"></svg-icon>
        <svg-icon name="bag"></svg-icon>
        <svg-icon name="pencil"></svg-icon>
      </div>
    </div>

    <img :src="stripImg" alt="图片" class="img-strip" />
    <!-- 内容区 -->
    <n-form
      ref="formRef"
      :label-width="80"
      :model="formValue"
      :rules="rules"
      :size="small"
      label-placement="left"
      label-width="auto"
      label-align="left"
    >
      <div class="content">
        <!-- 个人信息 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">基础信息</div>
          <div class="content-list-info">
            <div class="content-list-info-left">
              <n-form-item label="姓 名 :" path="name" size="small">
                <n-input
                  v-model:value="formValue.name"
                  placeholder="输入姓名"
                />
              </n-form-item>

              <n-form-item label="年 龄 :" path="age" size="small">
                <n-input v-model:value="formValue.age" placeholder="输入年龄" />
              </n-form-item>

              <n-form-item label="电 话 :" path="phone" size="small">
                <n-input
                  v-model:value="formValue.phone"
                  placeholder="电话号码"
                />
              </n-form-item>

              <n-form-item label="邮 箱 :" path="email" size="small">
                <n-input v-model:value="formValue.email" placeholder="邮箱" />
              </n-form-item>
            </div>
            <div class="avatar">
              <img src="../../../assets/imgs/resume/avatar.jpg" alt="" />

              <!-- <n-upload
                action="#"
                :default-file-list="previewFileList"
                list-type="image-card"
                @preview="handlePreview"
                max="1"
              /> -->
            </div>
          </div>
        </div>

        <!-- 教育经历 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">教育经历</div>
          <div class="content-list-info">
            <n-form-item path="educational_experience">
              <n-input
                v-model:value="formValue.educational_experience"
                type="textarea"
                placeholder="教育经历"
              />
            </n-form-item>
          </div>
        </div>

        <!-- 专业技能 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">专业技能</div>
          <div class="content-list-info">
            <n-form-item path="skill">
              <n-input
                v-model:value="formValue.skill"
                type="textarea"
                placeholder="专业技能"
              />
            </n-form-item>
          </div>
        </div>

        <!-- 项目经历 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">项目经历</div>
          <div class="content-list-info">
            <n-form-item size="small" path="project_experience">
              <n-input
                v-model:value="formValue.project_experience"
                type="textarea"
                placeholder="项目经历"
              />
            </n-form-item>
          </div>
        </div>

        <!-- 职位 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">期望职位</div>
          <div class="content-list-info">
            <n-form-item size="small" path="dream_position">
              <n-input
                v-model:value="formValue.dream_position"
                type="textarea"
                placeholder="输入期望职位"
              />
            </n-form-item>
          </div>
        </div>
        <!-- 薪水 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">期望薪水</div>
          <div class="content-list-info">
            <n-form-item size="small" path="dream_salary">
              <n-input
                v-model:value="formValue.dream_salary"
                type="textarea"
                placeholder="输入期望职位"
              />
            </n-form-item>
          </div>
        </div>

        <!-- 自我评价 -->
        <div class="content-list">
          <img :src="dividerImg" alt="" />
          <div class="content-list-title">自我评价</div>
          <div class="content-list-info">
            <n-form-item size="small" path="self_evaluation">
              <n-input
                v-model:value="formValue.self_evaluation"
                type="textarea"
                placeholder="自我评价"
              />
            </n-form-item>
          </div>
        </div>
      </div>
    </n-form>

    <div class="btn">
      <n-button type="primary" @click="generateResume"> 生成简历 </n-button>
    </div>
  </div>
</template>

<script>
//引入接口
import {
  getStudentInfo,
  getStudentPicture,
  editStudentInfo,
} from "@/http/api/student"
export default {
  data() {
    return {
      index: "",
      stripImg: [require("@/assets/imgs/resume/resume-strip.png")],
      dividerImg: [require("@/assets/imgs/resume/resume-divider.png")],

      formValue: {
        user_id: 5,
        name: "",
        age: "",
        educational_experience: "",
        skill: "",
        project_experience: "",
        dream_position: "",
        dream_salary: "",
        self_evaluation: "",
        email: "",
        phone: "",
        pages_id: 1,
      },
    }
  },

  mounted() {
    this.index = this.$route.params.index
    this.getInfo()
  },

  methods: {
    // 新增用户简历
    addResume() {
      //   addResumeAPI(this.formValue)
      //     .then((result) => {
      //       if (result.status === true) {
      //         window.$message.success("新增简历成功")
      // this.$router.push({
      //   name: "RESUMEPREVIEWONE",
      //   params: {
      //     id: this.formValue.user_id,
      //   },
      // })
      //   }
      // })
      // .catch((err) => {
      //   console.log(err)
      // })
    },

    generateResume() {
      this.editInfo()
      this.$router.push({
        path: "/resume-guidance/resume-preview-one",
      })
    },
    getInfo() {
      getStudentInfo()
        .then((result) => {
          // console.log(result.result[0])
          this.formValue = result.result[0]
        })
        .catch((err) => {
          console.log(err)
        })
    },
    editInfo() {
      editStudentInfo(this.formValue)
        .then((result) => {
          if (result.result.affectedRows == 1) {
            window.$message.success("编辑成功")
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
  },
}
</script>

<style lang="scss" scoped>
.btn {
  display: flex;
  justify-content: space-around;
}

.isShow {
  display: none;
}

.container {
  margin: 0px auto;
  width: 80%;
  padding: 20px 15px;
  background-color: #fff;
  .head {
    width: 100%;
    height: 80px;
    display: flex;
    .head-title {
      margin-top: 10px;
      font-size: 38px;
      font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
      color: #2c4d79;
    }

    .head-line {
      margin: 0px 10px;
      font-size: 50px;
    }

    .head-content {
      font-size: 25px;
    }

    .icon {
      margin-left: 220px;
      width: 300px;
      height: 300px;
      display: flex;
      justify-content: space-around;
      .svg-icon {
        width: 30px;
        height: 30px;
        padding: 10px;
        border-radius: 50%;
        background-color: #d2b48c;
        // border: 1px solid #f5f5f5;
        font-size: 35px;
      }
    }
  }

  .img-strip {
    width: 100%;
    height: 10px;
    margin-bottom: 22px;
  }

  .content {
    .content-list {
      position: relative;
      img {
        width: 100%;
        height: 40px;
      }
      .content-list-title {
        position: absolute;
        top: 8px;
        left: 55px;
      }

      .content-list-info {
        width: 98%;
        height: 100px;
        // background-color: aqua;
        display: flex;
        margin: 10px;
        justify-content: space-between; /* 横向中间自动空间 */

        ::v-deep .n-form-item {
          width: 100%;
          height: 100%;
        }

        .content-list-info-left {
          ::v-deep .n-form-item {
            height: 35px;
          }
          ::v-deep .n-form-item .n-input {
            margin-left: -25px;
            width: 220px;
          }

          display: flex;
          flex-direction: column;
          justify-content: space-around;
          padding: 15px;
        }
        .avatar {
          width: 80px;
          height: 100px;
          // background-color: #d2b48c;
          margin-right: 30px;

          img {
            object-fit: fill;
            width: 80px;
            height: 100px;
          }
        }
      }
    }
  }
}
</style>
